package cn.edu.ujn.park.service;

import cn.edu.ujn.park.dao.ParkingRecord;
import cn.edu.ujn.park.dao.ParkingRecordMapper;
import cn.edu.ujn.park.dao.ParkingSpace;
import cn.edu.ujn.park.dao.ParkingSpaceMapper;
import cn.edu.ujn.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ParkingRecordImpl implements IParkingRecord{

    @Autowired
    ParkingRecordMapper recordMapper;
    @Override
    public int deleteByPrimaryKey(Integer spaceId) {
        return recordMapper.deleteByPrimaryKey(spaceId);
    }

    @Override
    public int insert(ParkingRecord row) {
        return recordMapper.insert(row);
    }

    @Override
    public int insertSelective(ParkingRecord row) {
        return recordMapper.insertSelective(row);
    }

    @Override
    public ParkingRecord selectByPrimaryKey(Integer spaceId) {
        return recordMapper.selectByPrimaryKey(spaceId);
    }

    @Override
    public int updateByPrimaryKeySelective(ParkingRecord row) {
        return recordMapper.updateByPrimaryKeySelective(row);
    }

    @Override
    public int updateByPrimaryKey(ParkingRecord row) {
        return recordMapper.updateByPrimaryKey(row);
    }


    @Override
    public Page<ParkingRecord> selectAll(ParkingRecord parkingRecord) {
        Page<ParkingRecord> page = new Page<>();
        List<ParkingRecord> list = recordMapper.selectAll(parkingRecord);
        Integer count = recordMapper.selectCount();
        page.setRows(list);
        page.setPage(parkingRecord.getStart());
        page.setTotal(count);
        page.setSize(parkingRecord.getRows());
        return page;
    }

    @Override
    public Integer selectCount() {
        return recordMapper.selectCount();
    }

    @Override
    public List<ParkingRecord> selectByName(String vehicleName) {
        return null;
    }
}
